package domein;

/**
 * 
 * @author rensbonnez
 * When a peer logs on, all the files that are included in the shared
 * folder will be saved in this class.
 *
 */

public class PeerFile 
{
	private int fileId;
	private String fileName;
	private long fileSize;
	private String filePad;
	private String peerIp;
	
	public PeerFile(int fileId, String fileName, long fileSize, String filePad, String peerIp)
	{
		setFileId(fileId);
		setFileName(fileName);
		setFileSize(fileSize);
		setFilePad(filePad);
		setPeerIp(peerIp);
	}
	
	public PeerFile(int fileId, String fileName, long fileSize, String peerIp)
	{
		setFileId(fileId);
		setFileName(fileName);
		setFileSize(fileSize);
		setPeerIp(peerIp);
	}
	
	public String[] toArrayList()
	{
		String[] fileArray = new String[3];
		fileArray[0] = getFileName();
		fileArray[1] = Integer.toString(Integer.parseInt(Long.toBinaryString(getFileSize()), 2)/1000) + "kb";
		fileArray[2] = getPeerIp();
		
		return fileArray;
	}
	
	@Override
    /**
     * toString for output in GUI to show String fileName and Integer fileSize in KB as String
     * @return String
     */
    public String toString()
    {
        return getFileName() + " (" + String.valueOf(this.fileSize/1024) + " KB)";
    }
	
	/**
	 * 
	 * Getters & Setters
	 * 
	 */
	
	public int getFileId() {
		return fileId;
	}

	public void setFileId(int fileId) {
		this.fileId = fileId;
	}
	
	public String getFileName() {
		return fileName;
	}
	
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	
	public long getFileSize() {
		return fileSize;
	}
	
	public void setFileSize(long fileSize) {
		this.fileSize = fileSize;
	}
	
    public String getFilePad() {
		return filePad;
	}

	public void setFilePad(String filePad) {
		this.filePad = filePad;
	}

	public String getPeerIp() {
		return peerIp;
	}

	public void setPeerIp(String peerIp) {
		this.peerIp = peerIp;
	}
}
